

#include <wchar.h>
#include "Parser.h"
#include "Scanner.h"




void Parser::SynErr(int n) {
	if (errDist >= minErrDist) errors->SynErr(la->line, la->col, n);
	errDist = 0;
}

void Parser::SemErr(const wchar_t* msg) {
	if (errDist >= minErrDist) errors->Error(t->line, t->col, msg);
	errDist = 0;
}

void Parser::Get() {
	for (;;) {
		t = la;
		la = scanner->Scan();
		if (la->kind <= maxT) { ++errDist; break; }

		if (dummyToken != t) {
			dummyToken->kind = t->kind;
			dummyToken->pos = t->pos;
			dummyToken->col = t->col;
			dummyToken->line = t->line;
			dummyToken->next = NULL;
			coco_string_delete(dummyToken->val);
			dummyToken->val = coco_string_create(t->val);
			t = dummyToken;
		}
		la = t;
	}
}

void Parser::Expect(int n) {
	if (la->kind==n) Get(); else { SynErr(n); }
}

void Parser::ExpectWeak(int n, int follow) {
	if (la->kind == n) Get();
	else {
		SynErr(n);
		while (!StartOf(follow)) Get();
	}
}

bool Parser::WeakSeparator(int n, int syFol, int repFol) {
	if (la->kind == n) {Get(); return true;}
	else if (StartOf(repFol)) {return false;}
	else {
		SynErr(n);
		while (!(StartOf(syFol) || StartOf(repFol) || StartOf(0))) {
			Get();
		}
		return StartOf(syFol);
	}
}

void Parser::cmd() {
		if (StartOf(1)) {
			pred_cmd();
		} else if (StartOf(2)) {
			cmd_cmd();
		} else if (la->kind == 1) {
			comm_cmd();
		} else SynErr(221);
}

void Parser::pred_cmd() {
		if (StartOf(1)) {
			predicate();
		} else if (StartOf(1)) {
			predicate();
			direct_object();
			if (StartOf(3)) {
				prep_phrase();
				object();
			}
		} else if (StartOf(1)) {
			predicate();
			prep_phrase();
			direct_object();
		} else if (StartOf(1)) {
			predicate();
			determiner();
			direct_object();
			if (StartOf(3)) {
				prep_phrase();
				object();
			}
		} else if (StartOf(1)) {
			predicate();
			quantity();
			direct_object();
			if (la->kind == 69 || la->kind == 70 || la->kind == 71) {
				conjunction();
				object();
			}
		} else SynErr(222);
}

void Parser::cmd_cmd() {
		if (StartOf(4)) {
			no_arg_cmd();
		} else if (StartOf(5)) {
			one_arg_cmd();
		} else if (StartOf(6)) {
			two_arg_cmd();
		} else if (StartOf(7)) {
			three_arg_cmd();
		} else if (StartOf(8)) {
			four_arg_cmd();
		} else SynErr(223);
}

void Parser::comm_cmd() {
		Expect(1);
		Expect(72);
		string_list();
}

void Parser::predicate() {
		switch (la->kind) {
		case 2: {
			Get();
			break;
		}
		case 3: {
			Get();
			break;
		}
		case 4: {
			Get();
			break;
		}
		case 5: {
			Get();
			break;
		}
		case 6: {
			Get();
			break;
		}
		case 7: {
			Get();
			break;
		}
		case 8: {
			Get();
			break;
		}
		case 9: {
			Get();
			break;
		}
		case 10: {
			Get();
			break;
		}
		case 11: {
			Get();
			break;
		}
		case 12: {
			Get();
			break;
		}
		case 13: {
			Get();
			break;
		}
		case 14: {
			Get();
			break;
		}
		case 15: {
			Get();
			break;
		}
		case 16: {
			Get();
			break;
		}
		case 17: {
			Get();
			break;
		}
		case 18: {
			Get();
			break;
		}
		case 19: {
			Get();
			break;
		}
		case 20: {
			Get();
			break;
		}
		case 21: {
			Get();
			break;
		}
		case 22: {
			Get();
			break;
		}
		case 23: {
			Get();
			break;
		}
		case 24: {
			Get();
			break;
		}
		case 25: {
			Get();
			break;
		}
		case 26: {
			Get();
			break;
		}
		case 27: {
			Get();
			break;
		}
		case 28: {
			Get();
			break;
		}
		case 29: {
			Get();
			break;
		}
		case 30: {
			Get();
			break;
		}
		case 31: {
			Get();
			break;
		}
		case 32: {
			Get();
			break;
		}
		case 33: {
			Get();
			break;
		}
		case 34: {
			Get();
			break;
		}
		case 35: {
			Get();
			break;
		}
		case 36: {
			Get();
			break;
		}
		case 37: {
			Get();
			break;
		}
		case 38: {
			Get();
			break;
		}
		case 39: {
			Get();
			break;
		}
		case 40: {
			Get();
			break;
		}
		default: SynErr(224); break;
		}
}

void Parser::direct_object() {
		Expect(1);
}

void Parser::prep_phrase() {
		switch (la->kind) {
		case 41: {
			Get();
			break;
		}
		case 42: {
			Get();
			break;
		}
		case 43: {
			Get();
			break;
		}
		case 44: {
			Get();
			break;
		}
		case 45: {
			Get();
			break;
		}
		case 46: {
			Get();
			break;
		}
		case 47: {
			Get();
			break;
		}
		case 48: {
			Get();
			break;
		}
		case 49: {
			Get();
			break;
		}
		case 50: {
			Get();
			break;
		}
		case 51: {
			Get();
			break;
		}
		case 52: {
			Get();
			break;
		}
		case 53: {
			Get();
			break;
		}
		case 54: {
			Get();
			break;
		}
		case 55: {
			Get();
			break;
		}
		case 56: {
			Get();
			break;
		}
		case 57: {
			Get();
			break;
		}
		case 58: {
			Get();
			break;
		}
		case 59: {
			Get();
			break;
		}
		case 60: {
			Get();
			break;
		}
		case 61: {
			Get();
			break;
		}
		default: SynErr(225); break;
		}
		if (la->kind == 62) {
			Get();
		}
}

void Parser::object() {
		Expect(1);
}

void Parser::determiner() {
		if (la->kind == 63) {
			Get();
		} else if (la->kind == 64) {
			Get();
		} else if (la->kind == 62) {
			Get();
		} else SynErr(226);
}

void Parser::quantity() {
		if (la->kind == 65) {
			Get();
		} else if (la->kind == 66) {
			Get();
		} else if (la->kind == 63) {
			Get();
			Expect(67);
		} else if (la->kind == 68) {
			Get();
		} else SynErr(227);
}

void Parser::conjunction() {
		if (la->kind == 69) {
			Get();
		} else if (la->kind == 70) {
			Get();
		} else if (la->kind == 71) {
			Get();
		} else SynErr(228);
}

void Parser::string_list() {
		Expect(1);
		if (la->kind == 1) {
			string_list();
		}
}

void Parser::no_arg_cmd() {
		if (la->kind == 73) {
			Get();
		} else if (la->kind == 74) {
			Get();
		} else if (la->kind == 75) {
			Get();
		} else if (la->kind == 76) {
			Get();
		} else if (la->kind == 77) {
			Get();
		} else if (la->kind == 78) {
			Get();
		} else if (la->kind == 79) {
			Get();
		} else if (la->kind == 80) {
			Get();
		} else if (la->kind == 81) {
			Get();
		} else if (la->kind == 82) {
			Get();
		} else if (la->kind == 83) {
			Get();
		} else if (la->kind == 84) {
			Get();
		} else if (la->kind == 85) {
			Get();
		} else if (la->kind == 86) {
			Get();
		} else if (la->kind == 87) {
			Get();
		} else if (la->kind == 88) {
			Get();
		} else if (la->kind == 89) {
			Get();
		} else if (la->kind == 90) {
			Get();
		} else if (la->kind == 91) {
			Get();
		} else if (la->kind == 92) {
			Get();
		} else if (la->kind == 93) {
			Get();
		} else if (la->kind == 94) {
			Get();
		} else if (la->kind == 95) {
			Get();
		} else if (la->kind == 96) {
			Get();
		} else if (la->kind == 97) {
			Get();
		} else if (la->kind == 98) {
			Get();
		} else if (la->kind == 99) {
			Get();
		} else if (la->kind == 100) {
			Get();
		} else if (la->kind == 101) {
			Get();
		} else if (la->kind == 102) {
			Get();
		} else if (la->kind == 103) {
			Get();
		} else if (la->kind == 104) {
			Get();
		} else if (la->kind == 105) {
			Get();
		} else if (la->kind == 106) {
			Get();
		} else if (la->kind == 107) {
			Get();
			if (la->kind == 108 || la->kind == 109 || la->kind == 110) {
				if (la->kind == 108) {
					Get();
				} else {
					if (la->kind == 109) {
						Get();
					} else {
						Get();
					}
					Expect(1);
				}
			}
		} else if (la->kind == 111) {
			Get();
		} else if (la->kind == 112) {
			Get();
		} else if (la->kind == 113) {
			Get();
		} else if (la->kind == 114) {
			Get();
		} else if (la->kind == 115) {
			Get();
		} else if (la->kind == 116) {
			Get();
		} else if (la->kind == 117) {
			Get();
		} else if (la->kind == 118) {
			Get();
		} else if (la->kind == 119) {
			Get();
		} else if (la->kind == 120) {
			Get();
		} else if (la->kind == 121) {
			Get();
		} else if (la->kind == 122) {
			Get();
		} else if (la->kind == 123) {
			Get();
		} else if (la->kind == 124) {
			Get();
		} else if (la->kind == 125) {
			Get();
		} else if (la->kind == 126) {
			Get();
		} else if (la->kind == 127) {
			Get();
		} else if (la->kind == 128) {
			Get();
		} else if (la->kind == 129) {
			Get();
		} else if (la->kind == 129) {
			Get();
		} else if (la->kind == 60) {
			Get();
		} else if (la->kind == 130) {
			Get();
		} else if (la->kind == 131) {
			Get();
		} else if (la->kind == 132) {
			Get();
		} else if (la->kind == 133) {
			Get();
		} else if (la->kind == 134) {
			Get();
		} else if (la->kind == 135) {
			Get();
		} else if (la->kind == 136) {
			Get();
		} else if (la->kind == 137) {
			Get();
		} else if (la->kind == 138) {
			Get();
		} else if (la->kind == 139) {
			Get();
		} else SynErr(229);
}

void Parser::one_arg_cmd() {
		if (StartOf(9)) {
			switch (la->kind) {
			case 75: {
				Get();
				break;
			}
			case 140: {
				Get();
				break;
			}
			case 123: {
				Get();
				break;
			}
			case 141: {
				Get();
				break;
			}
			case 142: {
				Get();
				break;
			}
			case 143: {
				Get();
				break;
			}
			case 144: {
				Get();
				break;
			}
			case 139: {
				Get();
				break;
			}
			}
			string_list();
		} else if (StartOf(10)) {
			switch (la->kind) {
			case 145: {
				Get();
				break;
			}
			case 77: {
				Get();
				if (la->kind == 25) {
					Get();
				} else if (la->kind == 108) {
					Get();
				} else SynErr(230);
				break;
			}
			case 146: {
				Get();
				break;
			}
			case 147: {
				Get();
				break;
			}
			case 148: {
				Get();
				break;
			}
			case 149: {
				Get();
				break;
			}
			case 150: {
				Get();
				break;
			}
			case 151: {
				Get();
				break;
			}
			case 152: {
				Get();
				break;
			}
			case 153: {
				Get();
				break;
			}
			case 154: {
				Get();
				break;
			}
			case 155: {
				Get();
				break;
			}
			case 156: {
				Get();
				break;
			}
			case 157: {
				Get();
				break;
			}
			case 158: {
				Get();
				break;
			}
			case 159: {
				Get();
				break;
			}
			case 160: {
				Get();
				break;
			}
			case 161: {
				Get();
				break;
			}
			case 162: {
				Get();
				break;
			}
			}
			Expect(1);
		} else if (la->kind == 163) {
			Get();
			if (la->kind == 164) {
				Get();
			} else if (la->kind == 126) {
				Get();
			} else if (la->kind == 165) {
				Get();
			} else SynErr(231);
		} else if (la->kind == 108) {
			Get();
			if (la->kind == 166) {
				Get();
			} else if (la->kind == 167) {
				Get();
			} else SynErr(232);
		} else if (la->kind == 112) {
			Get();
			if (la->kind == 109 || la->kind == 110 || la->kind == 168) {
				if (la->kind == 109) {
					Get();
				} else if (la->kind == 110) {
					Get();
				} else {
					Get();
				}
				Expect(1);
			}
		} else SynErr(233);
}

void Parser::two_arg_cmd() {
		if (la->kind == 169) {
			Get();
			if (la->kind == 109) {
				Get();
			} else if (la->kind == 170) {
				Get();
			} else SynErr(234);
		} else if (la->kind == 171) {
			Get();
			Expect(1);
			Expect(1);
		} else if (la->kind == 172) {
			Get();
			if (la->kind == 173) {
				Get();
			} else if (la->kind == 109) {
				Get();
			} else if (la->kind == 168) {
				Get();
			} else if (la->kind == 174) {
				Get();
			} else SynErr(235);
			Expect(1);
		} else if (la->kind == 175) {
			Get();
			if (la->kind == 176) {
				Get();
			} else if (la->kind == 14) {
				Get();
			} else SynErr(236);
			Expect(1);
		} else if (la->kind == 98) {
			Get();
			if (la->kind == 177) {
				Get();
			} else if (la->kind == 110) {
				Get();
			} else SynErr(237);
			Expect(1);
		} else if (la->kind == 178) {
			Get();
			Expect(179);
			Expect(1);
		} else if (la->kind == 180) {
			Get();
			if (la->kind == 181) {
				Get();
			} else if (la->kind == 182) {
				Get();
			} else if (la->kind == 36) {
				Get();
			} else SynErr(238);
			Expect(1);
		} else if (la->kind == 183) {
			Get();
			if (la->kind == 109) {
				Get();
			} else if (la->kind == 110) {
				Get();
			} else if (la->kind == 168) {
				Get();
			} else SynErr(239);
			Expect(1);
		} else if (la->kind == 184) {
			Get();
			if (la->kind == 109) {
				Get();
			} else if (la->kind == 110) {
				Get();
			} else if (la->kind == 168) {
				Get();
			} else SynErr(240);
			Expect(1);
		} else if (la->kind == 76) {
			Get();
			if (la->kind == 109) {
				Get();
			} else if (la->kind == 110) {
				Get();
			} else if (la->kind == 173) {
				Get();
			} else if (la->kind == 168) {
				Get();
			} else SynErr(241);
			Expect(1);
		} else if (la->kind == 185) {
			Get();
			if (la->kind == 170) {
				Get();
			} else if (la->kind == 186) {
				Get();
			} else if (la->kind == 168) {
				Get();
			} else SynErr(242);
			Expect(1);
		} else if (la->kind == 183) {
			Get();
			if (la->kind == 29) {
				Get();
			} else if (la->kind == 109) {
				Get();
			} else if (la->kind == 110) {
				Get();
			} else if (la->kind == 186) {
				Get();
			} else if (la->kind == 168) {
				Get();
			} else SynErr(243);
			Expect(1);
		} else if (la->kind == 187) {
			Get();
			Expect(1);
			string_list();
		} else if (la->kind == 169) {
			Get();
			if (la->kind == 109) {
				Get();
			} else if (la->kind == 110) {
				Get();
			} else if (la->kind == 168) {
				Get();
			} else SynErr(244);
			Expect(1);
		} else if (la->kind == 131) {
			Get();
			Expect(188);
			string_list();
		} else if (la->kind == 145) {
			Get();
			Expect(1);
			string_list();
		} else if (la->kind == 189) {
			Get();
			switch (la->kind) {
			case 190: {
				Get();
				break;
			}
			case 191: {
				Get();
				break;
			}
			case 192: {
				Get();
				break;
			}
			case 109: {
				Get();
				break;
			}
			case 110: {
				Get();
				break;
			}
			case 168: {
				Get();
				break;
			}
			default: SynErr(245); break;
			}
			Expect(1);
		} else if (la->kind == 83) {
			Get();
			if (la->kind == 109) {
				Get();
			} else if (la->kind == 110) {
				Get();
			} else if (la->kind == 168) {
				Get();
			} else SynErr(246);
			Expect(1);
		} else if (la->kind == 193) {
			Get();
			if (la->kind == 109) {
				Get();
			} else if (la->kind == 110) {
				Get();
			} else if (la->kind == 168) {
				Get();
			} else SynErr(247);
			Expect(1);
		} else if (la->kind == 159) {
			Get();
			Expect(1);
			Expect(1);
		} else if (la->kind == 107) {
			Get();
			if (la->kind == 24) {
				Get();
			} else if (la->kind == 110) {
				Get();
			} else if (la->kind == 179) {
				Get();
			} else SynErr(248);
			Expect(1);
		} else SynErr(249);
}

void Parser::three_arg_cmd() {
		if (la->kind == 175) {
			Get();
			Expect(1);
			Expect(194);
			Expect(151);
		} else if (la->kind == 195) {
			Get();
			Expect(1);
			Expect(1);
			Expect(1);
		} else if (la->kind == 196) {
			Get();
			if (la->kind == 109) {
				Get();
				item_type();
			} else if (la->kind == 170) {
				Get();
			} else if (la->kind == 168) {
				Get();
			} else SynErr(250);
			Expect(1);
		} else if (la->kind == 189) {
			Get();
			if (la->kind == 4) {
				Get();
				Expect(1);
			} else if (la->kind == 27) {
				Get();
				Expect(1);
				Expect(197);
				Expect(1);
			} else SynErr(251);
		} else if (la->kind == 98) {
			Get();
			Expect(198);
			Expect(1);
			string_list();
		} else SynErr(252);
}

void Parser::four_arg_cmd() {
		switch (la->kind) {
		case 76: {
			Get();
			break;
		}
		case 169: {
			Get();
			break;
		}
		case 172: {
			Get();
			break;
		}
		case 193: {
			Get();
			break;
		}
		case 183: {
			Get();
			break;
		}
		case 196: {
			Get();
			break;
		}
		default: SynErr(253); break;
		}
		Expect(1);
		Expect(188);
		Expect(1);
		string_list();
}

void Parser::item_type() {
		switch (la->kind) {
		case 199: {
			Get();
			break;
		}
		case 200: {
			Get();
			break;
		}
		case 201: {
			Get();
			break;
		}
		case 202: {
			Get();
			break;
		}
		case 203: {
			Get();
			break;
		}
		case 204: {
			Get();
			break;
		}
		case 205: {
			Get();
			break;
		}
		case 206: {
			Get();
			break;
		}
		case 207: {
			Get();
			break;
		}
		case 208: case 209: case 210: {
			if (la->kind == 208) {
				Get();
			} else if (la->kind == 209) {
				Get();
			} else {
				Get();
			}
			Expect(211);
			break;
		}
		case 212: {
			Get();
			break;
		}
		case 213: {
			Get();
			break;
		}
		case 214: {
			Get();
			break;
		}
		case 215: {
			Get();
			break;
		}
		case 216: {
			Get();
			break;
		}
		case 217: {
			Get();
			if (la->kind == 218) {
				Get();
			} else if (la->kind == 219) {
				Get();
			} else SynErr(254);
			break;
		}
		default: SynErr(255); break;
		}
}




// If the user declared a method Init and a mehtod Destroy they should
// be called in the contructur and the destructor respctively.
//
// The following templates are used to recognize if the user declared
// the methods Init and Destroy.

template<typename T>
struct ParserInitExistsRecognizer {
	template<typename U, void (U::*)() = &U::Init>
	struct ExistsIfInitIsDefinedMarker{};

	struct InitIsMissingType {
		char dummy1;
	};
	
	struct InitExistsType {
		char dummy1; char dummy2;
	};

	// exists always
	template<typename U>
	static InitIsMissingType is_here(...);

	// exist only if ExistsIfInitIsDefinedMarker is defined
	template<typename U>
	static InitExistsType is_here(ExistsIfInitIsDefinedMarker<U>*);

	enum { InitExists = (sizeof(is_here<T>(NULL)) == sizeof(InitExistsType)) };
};

template<typename T>
struct ParserDestroyExistsRecognizer {
	template<typename U, void (U::*)() = &U::Destroy>
	struct ExistsIfDestroyIsDefinedMarker{};

	struct DestroyIsMissingType {
		char dummy1;
	};
	
	struct DestroyExistsType {
		char dummy1; char dummy2;
	};

	// exists always
	template<typename U>
	static DestroyIsMissingType is_here(...);

	// exist only if ExistsIfDestroyIsDefinedMarker is defined
	template<typename U>
	static DestroyExistsType is_here(ExistsIfDestroyIsDefinedMarker<U>*);

	enum { DestroyExists = (sizeof(is_here<T>(NULL)) == sizeof(DestroyExistsType)) };
};

// The folloing templates are used to call the Init and Destroy methods if they exist.

// Generic case of the ParserInitCaller, gets used if the Init method is missing
template<typename T, bool = ParserInitExistsRecognizer<T>::InitExists>
struct ParserInitCaller {
	static void CallInit(T *t) {
		// nothing to do
	}
};

// True case of the ParserInitCaller, gets used if the Init method exists
template<typename T>
struct ParserInitCaller<T, true> {
	static void CallInit(T *t) {
		t->Init();
	}
};

// Generic case of the ParserDestroyCaller, gets used if the Destroy method is missing
template<typename T, bool = ParserDestroyExistsRecognizer<T>::DestroyExists>
struct ParserDestroyCaller {
	static void CallDestroy(T *t) {
		// nothing to do
	}
};

// True case of the ParserDestroyCaller, gets used if the Destroy method exists
template<typename T>
struct ParserDestroyCaller<T, true> {
	static void CallDestroy(T *t) {
		t->Destroy();
	}
};

void Parser::Parse() {
	t = NULL;
	la = dummyToken = new Token();
	la->val = coco_string_create(L"Dummy Token");
	Get();
	cmd();
	Expect(0);
}

Parser::Parser(Scanner *scanner) {
	maxT = 220;

	ParserInitCaller<Parser>::CallInit(this);
	dummyToken = NULL;
	t = la = NULL;
	minErrDist = 2;
	errDist = minErrDist;
	this->scanner = scanner;
	errors = new Errors();
}

bool Parser::StartOf(int s) {
	const bool T = true;
	const bool x = false;

	static bool set[11][222] = {
		{T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
		{x,x,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
		{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,x,x,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,T,x,T, T,x,x,T, x,x,T,x, T,x,x,T, T,T,x,T, x,T,x,x, x,T,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
		{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
		{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, x,x,x,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
		{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, T,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
		{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,T, T,x,x,T, x,x,T,x, T,x,x,T, T,T,x,T, x,T,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
		{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
		{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, T,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,T,x,x, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
		{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,T, T,T,T,T, T,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x},
		{x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,T,T,T, T,T,T,T, T,T,T,T, T,T,T,T, T,T,T,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x,x,x, x,x}
	};



	return set[s][la->kind];
}

Parser::~Parser() {
	ParserDestroyCaller<Parser>::CallDestroy(this);
	delete errors;
	delete dummyToken;
}

Errors::Errors() {
	count = 0;
}

void Errors::SynErr(int line, int col, int n) {
	wchar_t* s;
	switch (n) {
			case 0: s = coco_string_create(L"EOF expected"); break;
			case 1: s = coco_string_create(L"ident expected"); break;
			case 2: s = coco_string_create(L"\"ask\" expected"); break;
			case 3: s = coco_string_create(L"\"attack\" expected"); break;
			case 4: s = coco_string_create(L"\"buy\" expected"); break;
			case 5: s = coco_string_create(L"\"cast\" expected"); break;
			case 6: s = coco_string_create(L"\"climb\" expected"); break;
			case 7: s = coco_string_create(L"\"cover\" expected"); break;
			case 8: s = coco_string_create(L"\"crouch\" expected"); break;
			case 9: s = coco_string_create(L"\"draw\" expected"); break;
			case 10: s = coco_string_create(L"\"drop\" expected"); break;
			case 11: s = coco_string_create(L"\"duel\" expected"); break;
			case 12: s = coco_string_create(L"\"emote\" expected"); break;
			case 13: s = coco_string_create(L"\"enter\" expected"); break;
			case 14: s = coco_string_create(L"\"examine\" expected"); break;
			case 15: s = coco_string_create(L"\"follow\" expected"); break;
			case 16: s = coco_string_create(L"\"get\" expected"); break;
			case 17: s = coco_string_create(L"\"give\" expected"); break;
			case 18: s = coco_string_create(L"\"me\" expected"); break;
			case 19: s = coco_string_create(L"\"open\" expected"); break;
			case 20: s = coco_string_create(L"\"pick\" expected"); break;
			case 21: s = coco_string_create(L"\"push\" expected"); break;
			case 22: s = coco_string_create(L"\"put\" expected"); break;
			case 23: s = coco_string_create(L"\"recite\" expected"); break;
			case 24: s = coco_string_create(L"\"read\" expected"); break;
			case 25: s = coco_string_create(L"\"remove\" expected"); break;
			case 26: s = coco_string_create(L"\"repair\" expected"); break;
			case 27: s = coco_string_create(L"\"sell\" expected"); break;
			case 28: s = coco_string_create(L"\"shout\" expected"); break;
			case 29: s = coco_string_create(L"\"show\" expected"); break;
			case 30: s = coco_string_create(L"\"sit\" expected"); break;
			case 31: s = coco_string_create(L"\"stand\" expected"); break;
			case 32: s = coco_string_create(L"\"take\" expected"); break;
			case 33: s = coco_string_create(L"\"throw\" expected"); break;
			case 34: s = coco_string_create(L"\"unwear\" expected"); break;
			case 35: s = coco_string_create(L"\"turn\" expected"); break;
			case 36: s = coco_string_create(L"\"unload\" expected"); break;
			case 37: s = coco_string_create(L"\"unlock\" expected"); break;
			case 38: s = coco_string_create(L"\"unwield\" expected"); break;
			case 39: s = coco_string_create(L"\"wear\" expected"); break;
			case 40: s = coco_string_create(L"\"wield\" expected"); break;
			case 41: s = coco_string_create(L"\"on\" expected"); break;
			case 42: s = coco_string_create(L"\"of\" expected"); break;
			case 43: s = coco_string_create(L"\"above\" expected"); break;
			case 44: s = coco_string_create(L"\"below\" expected"); break;
			case 45: s = coco_string_create(L"\"under\" expected"); break;
			case 46: s = coco_string_create(L"\"in\" expected"); break;
			case 47: s = coco_string_create(L"\"to\" expected"); break;
			case 48: s = coco_string_create(L"\"across\" expected"); break;
			case 49: s = coco_string_create(L"\"against\" expected"); break;
			case 50: s = coco_string_create(L"\"at\" expected"); break;
			case 51: s = coco_string_create(L"\"before\" expected"); break;
			case 52: s = coco_string_create(L"\"behind\" expected"); break;
			case 53: s = coco_string_create(L"\"beneath\" expected"); break;
			case 54: s = coco_string_create(L"\"beside\" expected"); break;
			case 55: s = coco_string_create(L"\"between\" expected"); break;
			case 56: s = coco_string_create(L"\"by\" expected"); break;
			case 57: s = coco_string_create(L"\"from\" expected"); break;
			case 58: s = coco_string_create(L"\"into\" expected"); break;
			case 59: s = coco_string_create(L"\"upon\" expected"); break;
			case 60: s = coco_string_create(L"\"up\" expected"); break;
			case 61: s = coco_string_create(L"\"inside\" expected"); break;
			case 62: s = coco_string_create(L"\"the\" expected"); break;
			case 63: s = coco_string_create(L"\"a\" expected"); break;
			case 64: s = coco_string_create(L"\"an\" expected"); break;
			case 65: s = coco_string_create(L"\"all\" expected"); break;
			case 66: s = coco_string_create(L"\"some\" expected"); break;
			case 67: s = coco_string_create(L"\"few\" expected"); break;
			case 68: s = coco_string_create(L"\"none\" expected"); break;
			case 69: s = coco_string_create(L"\"and\" expected"); break;
			case 70: s = coco_string_create(L"\"but\" expected"); break;
			case 71: s = coco_string_create(L"\"or\" expected"); break;
			case 72: s = coco_string_create(L"\",\" expected"); break;
			case 73: s = coco_string_create(L"\"about\" expected"); break;
			case 74: s = coco_string_create(L"\"account\" expected"); break;
			case 75: s = coco_string_create(L"\"afk\" expected"); break;
			case 76: s = coco_string_create(L"\"agency\" expected"); break;
			case 77: s = coco_string_create(L"\"assignments\" expected"); break;
			case 78: s = coco_string_create(L"\"autoloot\" expected"); break;
			case 79: s = coco_string_create(L"\"awards\" expected"); break;
			case 80: s = coco_string_create(L"\"background\" expected"); break;
			case 81: s = coco_string_create(L"\"bug\" expected"); break;
			case 82: s = coco_string_create(L"\"callcontrol\" expected"); break;
			case 83: s = coco_string_create(L"\"character\" expected"); break;
			case 84: s = coco_string_create(L"\"commands\" expected"); break;
			case 85: s = coco_string_create(L"\"cooldowns\" expected"); break;
			case 86: s = coco_string_create(L"\"coordinates\" expected"); break;
			case 87: s = coco_string_create(L"\"disband\" expected"); break;
			case 88: s = coco_string_create(L"\"dossier\" expected"); break;
			case 89: s = coco_string_create(L"\"down\" expected"); break;
			case 90: s = coco_string_create(L"\"east\" expected"); break;
			case 91: s = coco_string_create(L"\"d\" expected"); break;
			case 92: s = coco_string_create(L"\"e\" expected"); break;
			case 93: s = coco_string_create(L"\"conditions\" expected"); break;
			case 94: s = coco_string_create(L"\"emotes\" expected"); break;
			case 95: s = coco_string_create(L"\"entrances\" expected"); break;
			case 96: s = coco_string_create(L"\"exits\" expected"); break;
			case 97: s = coco_string_create(L"\"faq\" expected"); break;
			case 98: s = coco_string_create(L"\"friends\" expected"); break;
			case 99: s = coco_string_create(L"\"help\" expected"); break;
			case 100: s = coco_string_create(L"\"history\" expected"); break;
			case 101: s = coco_string_create(L"\"idea\" expected"); break;
			case 102: s = coco_string_create(L"\"inventory\" expected"); break;
			case 103: s = coco_string_create(L"\"i\" expected"); break;
			case 104: s = coco_string_create(L"\"last\" expected"); break;
			case 105: s = coco_string_create(L"\"listen\" expected"); break;
			case 106: s = coco_string_create(L"\"log\" expected"); break;
			case 107: s = coco_string_create(L"\"mail\" expected"); break;
			case 108: s = coco_string_create(L"\"list\" expected"); break;
			case 109: s = coco_string_create(L"\"create\" expected"); break;
			case 110: s = coco_string_create(L"\"delete\" expected"); break;
			case 111: s = coco_string_create(L"\"motd\" expected"); break;
			case 112: s = coco_string_create(L"\"news\" expected"); break;
			case 113: s = coco_string_create(L"\"north\" expected"); break;
			case 114: s = coco_string_create(L"\"n\" expected"); break;
			case 115: s = coco_string_create(L"\"occupation\" expected"); break;
			case 116: s = coco_string_create(L"\"profession\" expected"); break;
			case 117: s = coco_string_create(L"\"quit\" expected"); break;
			case 118: s = coco_string_create(L"\"reboot\" expected"); break;
			case 119: s = coco_string_create(L"\"rest\" expected"); break;
			case 120: s = coco_string_create(L"\"south\" expected"); break;
			case 121: s = coco_string_create(L"\"s\" expected"); break;
			case 122: s = coco_string_create(L"\"save\" expected"); break;
			case 123: s = coco_string_create(L"\"shutdown\" expected"); break;
			case 124: s = coco_string_create(L"\"socials\" expected"); break;
			case 125: s = coco_string_create(L"\"spells\" expected"); break;
			case 126: s = coco_string_create(L"\"stats\" expected"); break;
			case 127: s = coco_string_create(L"\"tasks\" expected"); break;
			case 128: s = coco_string_create(L"\"team\" expected"); break;
			case 129: s = coco_string_create(L"\"train\" expected"); break;
			case 130: s = coco_string_create(L"\"u\" expected"); break;
			case 131: s = coco_string_create(L"\"title\" expected"); break;
			case 132: s = coco_string_create(L"\"uptime\" expected"); break;
			case 133: s = coco_string_create(L"\"users\" expected"); break;
			case 134: s = coco_string_create(L"\"version\" expected"); break;
			case 135: s = coco_string_create(L"\"west\" expected"); break;
			case 136: s = coco_string_create(L"\"w\" expected"); break;
			case 137: s = coco_string_create(L"\"who\" expected"); break;
			case 138: s = coco_string_create(L"\"reghelper\" expected"); break;
			case 139: s = coco_string_create(L"\"jargon\" expected"); break;
			case 140: s = coco_string_create(L"\"describe\" expected"); break;
			case 141: s = coco_string_create(L"\"doing\" expected"); break;
			case 142: s = coco_string_create(L"\"wallops\" expected"); break;
			case 143: s = coco_string_create(L"\"wall\" expected"); break;
			case 144: s = coco_string_create(L"\"say\" expected"); break;
			case 145: s = coco_string_create(L"\"ban\" expected"); break;
			case 146: s = coco_string_create(L"\"consider\" expected"); break;
			case 147: s = coco_string_create(L"\"finger\" expected"); break;
			case 148: s = coco_string_create(L"\"ignore\" expected"); break;
			case 149: s = coco_string_create(L"\"invite\" expected"); break;
			case 150: s = coco_string_create(L"\"locate\" expected"); break;
			case 151: s = coco_string_create(L"\"passwd\" expected"); break;
			case 152: s = coco_string_create(L"\"recruit\" expected"); break;
			case 153: s = coco_string_create(L"\"seen\" expected"); break;
			case 154: s = coco_string_create(L"\"skill\" expected"); break;
			case 155: s = coco_string_create(L"\"teleport\" expected"); break;
			case 156: s = coco_string_create(L"\"trait\" expected"); break;
			case 157: s = coco_string_create(L"\"wait\" expected"); break;
			case 158: s = coco_string_create(L"\"whois\" expected"); break;
			case 159: s = coco_string_create(L"\"talent\" expected"); break;
			case 160: s = coco_string_create(L"\"find\" expected"); break;
			case 161: s = coco_string_create(L"\"run\" expected"); break;
			case 162: s = coco_string_create(L"\"man\" expected"); break;
			case 163: s = coco_string_create(L"\"dump\" expected"); break;
			case 164: s = coco_string_create(L"\"db\" expected"); break;
			case 165: s = coco_string_create(L"\"memory\" expected"); break;
			case 166: s = coco_string_create(L"\"tables\" expected"); break;
			case 167: s = coco_string_create(L"\"queues\" expected"); break;
			case 168: s = coco_string_create(L"\"edit\" expected"); break;
			case 169: s = coco_string_create(L"\"area\" expected"); break;
			case 170: s = coco_string_create(L"\"destroy\" expected"); break;
			case 171: s = coco_string_create(L"\"bounty\" expected"); break;
			case 172: s = coco_string_create(L"\"channel\" expected"); break;
			case 173: s = coco_string_create(L"\"join\" expected"); break;
			case 174: s = coco_string_create(L"\"close\" expected"); break;
			case 175: s = coco_string_create(L"\"client\" expected"); break;
			case 176: s = coco_string_create(L"\"disconnect\" expected"); break;
			case 177: s = coco_string_create(L"\"add\" expected"); break;
			case 178: s = coco_string_create(L"\"message\" expected"); break;
			case 179: s = coco_string_create(L"\"send\" expected"); break;
			case 180: s = coco_string_create(L"\"module\" expected"); break;
			case 181: s = coco_string_create(L"\"reload\" expected"); break;
			case 182: s = coco_string_create(L"\"load\" expected"); break;
			case 183: s = coco_string_create(L"\"npc\" expected"); break;
			case 184: s = coco_string_create(L"\"room\" expected"); break;
			case 185: s = coco_string_create(L"\"object\" expected"); break;
			case 186: s = coco_string_create(L"\"clone\" expected"); break;
			case 187: s = coco_string_create(L"\"tell\" expected"); break;
			case 188: s = coco_string_create(L"\"set\" expected"); break;
			case 189: s = coco_string_create(L"\"shop\" expected"); break;
			case 190: s = coco_string_create(L"\"owner\" expected"); break;
			case 191: s = coco_string_create(L"\"deposit\" expected"); break;
			case 192: s = coco_string_create(L"\"withdraw\" expected"); break;
			case 193: s = coco_string_create(L"\"door\" expected"); break;
			case 194: s = coco_string_create(L"\"reset\" expected"); break;
			case 195: s = coco_string_create(L"\"giveitem\" expected"); break;
			case 196: s = coco_string_create(L"\"item\" expected"); break;
			case 197: s = coco_string_create(L"\"for\" expected"); break;
			case 198: s = coco_string_create(L"\"note\" expected"); break;
			case 199: s = coco_string_create(L"\"improvised\" expected"); break;
			case 200: s = coco_string_create(L"\"axe\" expected"); break;
			case 201: s = coco_string_create(L"\"mace\" expected"); break;
			case 202: s = coco_string_create(L"\"sword\" expected"); break;
			case 203: s = coco_string_create(L"\"spear\" expected"); break;
			case 204: s = coco_string_create(L"\"knife\" expected"); break;
			case 205: s = coco_string_create(L"\"knuckles\" expected"); break;
			case 206: s = coco_string_create(L"\"club\" expected"); break;
			case 207: s = coco_string_create(L"\"handgun\" expected"); break;
			case 208: s = coco_string_create(L"\"assault\" expected"); break;
			case 209: s = coco_string_create(L"\"bolt\" expected"); break;
			case 210: s = coco_string_create(L"\"sniper\" expected"); break;
			case 211: s = coco_string_create(L"\"rifle\" expected"); break;
			case 212: s = coco_string_create(L"\"shotgun\" expected"); break;
			case 213: s = coco_string_create(L"\"submachinegun\" expected"); break;
			case 214: s = coco_string_create(L"\"machinegun\" expected"); break;
			case 215: s = coco_string_create(L"\"explosive\" expected"); break;
			case 216: s = coco_string_create(L"\"hurld\" expected"); break;
			case 217: s = coco_string_create(L"\"exotic\" expected"); break;
			case 218: s = coco_string_create(L"\"ranged\" expected"); break;
			case 219: s = coco_string_create(L"\"melee\" expected"); break;
			case 220: s = coco_string_create(L"??? expected"); break;
			case 221: s = coco_string_create(L"invalid cmd"); break;
			case 222: s = coco_string_create(L"invalid pred_cmd"); break;
			case 223: s = coco_string_create(L"invalid cmd_cmd"); break;
			case 224: s = coco_string_create(L"invalid predicate"); break;
			case 225: s = coco_string_create(L"invalid prep_phrase"); break;
			case 226: s = coco_string_create(L"invalid determiner"); break;
			case 227: s = coco_string_create(L"invalid quantity"); break;
			case 228: s = coco_string_create(L"invalid conjunction"); break;
			case 229: s = coco_string_create(L"invalid no_arg_cmd"); break;
			case 230: s = coco_string_create(L"invalid one_arg_cmd"); break;
			case 231: s = coco_string_create(L"invalid one_arg_cmd"); break;
			case 232: s = coco_string_create(L"invalid one_arg_cmd"); break;
			case 233: s = coco_string_create(L"invalid one_arg_cmd"); break;
			case 234: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 235: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 236: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 237: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 238: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 239: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 240: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 241: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 242: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 243: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 244: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 245: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 246: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 247: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 248: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 249: s = coco_string_create(L"invalid two_arg_cmd"); break;
			case 250: s = coco_string_create(L"invalid three_arg_cmd"); break;
			case 251: s = coco_string_create(L"invalid three_arg_cmd"); break;
			case 252: s = coco_string_create(L"invalid three_arg_cmd"); break;
			case 253: s = coco_string_create(L"invalid four_arg_cmd"); break;
			case 254: s = coco_string_create(L"invalid item_type"); break;
			case 255: s = coco_string_create(L"invalid item_type"); break;

		default:
		{
			wchar_t format[20];
			coco_swprintf(format, 20, L"error %d", n);
			s = coco_string_create(format);
		}
		break;
	}
	wprintf(L"-- line %d col %d: %ls\n", line, col, s);
	coco_string_delete(s);
	count++;
}

void Errors::Error(int line, int col, const wchar_t *s) {
	wprintf(L"-- line %d col %d: %ls\n", line, col, s);
	count++;
}

void Errors::Warning(int line, int col, const wchar_t *s) {
	wprintf(L"-- line %d col %d: %ls\n", line, col, s);
}

void Errors::Warning(const wchar_t *s) {
	wprintf(L"%ls\n", s);
}

void Errors::Exception(const wchar_t* s) {
	wprintf(L"%ls", s); 
	exit(1);
}


